package cn.sanxintong.utils.generate;

import java.io.File;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import cn.sanxintong.entity.constant.Constant;
import cn.sanxintong.entity.constant.FileConstant;
import cn.sanxintong.utils.freemarker.FreeMarkerTemplateUtils;

/**
 * DAO 工具类
 * @author hxy
 * @version 1.0.0
 */
public class DAOUtil {
	/**
	 * 生成DAO文件
	 * @param resultSet
	 * @throws Exception
	 */
	public static void generateDaoFile(ResultSet resultSet) throws Exception{
        final String path = Constant.DISK_PATH + StringUtils.substring(Constant.CHANGE_TABLE_NAME, 3) + FileConstant.DAO_SUFFIX;
        final String templateName = "DAO.ftl";
        File mapperFile = new File(path);
        Map<String,Object> dataMap = new HashMap<>();
        FreeMarkerTemplateUtils.generateFileByTemplate(templateName,mapperFile,dataMap);
        System.out.println("dao生成了");
    }
}
